/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package AplManager.controller;
import AplManager.views.*;
import AplManager.models.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
 *
 * @author user
 */
public class EnterFormController {
     //private TableDisplayy view;
     private EnterForm view;
    private ActionListener actionListener;
    
    public EnterFormController(EnterForm view){
       this.view  = view;
    }
    
    public void control(){        
        actionListener = new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) { 
                  if(e.getSource().equals(view.getEnterBtn())){
                  //AddPlayer addplayer = new AddPlayer();
                  TableDisplay tblView = new TableDisplay();
                  Team team = new Team(view.getTeamID(),view.getTeamName());
                 DBcontroller dbControl = new DBcontroller(tblView,team);
                 dbControl.initialize();
                 dbControl.set();
                 tblView.setVisible(true);
                 TableDisplayController control = new TableDisplayController(team,tblView,dbControl);
                 control.control();
                 view.setVisible(false);
                  }
              }
        };                
        view.getEnterBtn().addActionListener(actionListener);
    }
}
